﻿using BlogApi.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BlogApi.Services
{
    /// <summary>
    /// 粉丝表仓储接口
    /// </summary>
    public interface IFanRepository
    {
        /// <summary>
        /// 获取对应作者的粉丝
        /// </summary>
        /// <param name="authorId"></param>
        /// <returns></returns>
        Task<IEnumerable<Fan>> GetFansAsync(Guid authorId);
        /// <summary>
        /// 获取分页后的对应作者的粉丝
        /// </summary>
        /// <param name="authorId"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        Task<IEnumerable<Fan>> GetFansByPageAsync(Guid authorId, int pageSize, int pageIndex);
        /// <summary>
        /// 获取分页后用户关注的作者
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        Task<IEnumerable<Fan>> GetUserFocusByPageAsync(Guid userId, int pageSize, int pageIndex);
        /// <summary>
        /// 根据ID获取对应数据
        /// </summary>
        /// <param name="id">粉丝表的ID</param>
        /// <returns></returns>
        Task<Fan> GetFanAsync(Guid id);
        /// <summary>
        /// 根据作者ID和用户ID获取实体
        /// </summary>
        /// <param name="authorId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        Task<Fan> GetFanAsync(Guid authorId, Guid userId);
        /// <summary>
        /// fan表新增一个数据
        /// </summary>
        /// <param name="fan"></param>
        void AddFan(Fan fan);
        /// <summary>
        /// 更新fan表的一个数据
        /// </summary>
        /// <param name="fan"></param>
        void UpdateFan(Fan fan);
        /// <summary>
        /// 删除一个粉丝
        /// </summary>
        /// <param name="fan"></param>
        void DeleteFan(Fan fan);
        /// <summary>
        /// 根据ID判断这条数据是否存在
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<bool> FanExistsAsync(Guid id);
        /// <summary>
        /// 判断用户是否是该作者粉丝
        /// </summary>
        /// <param name="authorId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        Task<bool> AuthorUserExistsAsync(Guid authorId, Guid userId);
        /// <summary>
        /// 保存更改到数据库
        /// </summary>
        /// <returns></returns>
        Task<bool> SaveAsync();
    }
}
